package com.qianli.cashmama.product.server.entity;
import com.fqgj.common.entity.BaseEntity;
import com.qianli.cashmama.product.facade.enums.ErrorCodeEnum;
import com.qianli.cashmama.product.facade.enums.InterestStrategyEnum;
import com.qianli.cashmama.product.facade.enums.PaybackPeriodUnitEnum;
import com.qianli.cashmama.product.facade.enums.SellStatusEnum;
import com.qianli.cashmama.product.facade.result.CategoryConfig;
import com.qianli.cashmama.product.facade.result.ProductCategory;
import com.qianli.cashmama.product.server.domain.ProductCategoryDomain;
import com.qianli.cashmama.product.server.exception.ProductException;

import java.math.BigDecimal;
import java.util.Date;
/**
* User: anonymous
* Date: 2021-11-12
* Time: 20:02:51.306
* TableDesc:
*/
public class ProductCategoryEntity extends BaseEntity{
    /**
    *机构code
    */
    private String merchantCode;
    /**
    *类目编码
    */
    private String code;
    /**
    *类目名称
    */
    private String name;
    /**
    *类目金额下限
    */
    private BigDecimal moneyFloor;
    /**
    *类目金额上限
    */
    private BigDecimal moneyUpper;
    /**
    *是否上架,0否,1是
    */
    private Integer isSelling;
    /**
    *计息规则,枚举 (未启用)
    */
    private String interestStrategy;
    /**
    *还款周期单位,枚举 DAY("DAY", "天"), WEEK("WEEK", "周"), MONTH("MONTH", "月"), YEAR("YEAR", "年")
    */
    private String paybackPeriodUnit;
    /**
    *还款周期下限
    */
    private Integer paybackPeriodFloor;
    /**
    *还款周期上限
    */
    private Integer paybackPeriodUpper;
    /**
    *每档金额
    */
    private BigDecimal moneyStep;
    /**
    *每档还款周期
    */
    private Integer paybackPeriodStep;
    /**
    *排序号
    */
    private Integer sort;
    /**
    *类目编码
    */
    private String logo;
    /**
    *申请比例
    */
    private Integer applyRate;
    /**
    *类目类型 1：推荐位 2：热点 3：普通
    */
    private Integer categoryType;
    /**
    *类目描述
    */
    private String categoryDesc;
    /**
    *每日申请上限
    */
    private Integer dailyApplyLimit;
    /**
    *生效开始时间
    */
    private Date effectiveStartTime;
    /**
    *生效结束时间
    */
    private Date effectiveEndTime;
    /**
    *商户域名
    */
    private String merchantDoaminUrl;
    /**
    *商户公钥
    */
    private String merchantPublicKey;
    /**
    *确认提现步骤
    */
    private Integer confirmWithdrawProcess;
    /**
    *商户公钥
    */
    private String extraInfo;
    /**
    *为谷歌上架准备的
    */
    private Integer forGp;


    public  String getMerchantCode(){
        return this.merchantCode;
    }

    public  ProductCategoryEntity setMerchantCode(String merchantCode){
        this.merchantCode = merchantCode;
        return this;
    }

    public ProductCategoryDomain toDomain() {
        ProductCategoryDomain domain = new ProductCategoryDomain();
        domain.setCode(this.getCode());
        domain.setName(this.getName());
        domain.setMoneyFloor(this.getMoneyFloor());
        domain.setMoneyUpper(this.getMoneyUpper());
        domain.setMoneyStep(this.getMoneyStep());
        SellStatusEnum isSelling = SellStatusEnum.getByStatus(this.getIsSelling());
        if (isSelling == null) {
            throw new ProductException(ErrorCodeEnum.INVALID_SELLING_STATUS);
        }
        domain.setIsSelling(isSelling);
        InterestStrategyEnum interestStrategy = InterestStrategyEnum.getByCode(this.getInterestStrategy());
        if (interestStrategy == null) {
            throw new ProductException(ErrorCodeEnum.INVALID_INTEREST_STRATEGY);
        }
        domain.setInterestStrategy(interestStrategy);
        PaybackPeriodUnitEnum paybackPeriodUnitEnum = PaybackPeriodUnitEnum.getByCode(this.getPaybackPeriodUnit());
        if (paybackPeriodUnitEnum == null) {
            throw new ProductException(ErrorCodeEnum.INVALID_PAYBACK_PERIOD_UNIT);
        }
        domain.setPaybackPeriodUnitEnum(paybackPeriodUnitEnum);
        domain.setPaybackPeriodFloor(this.getPaybackPeriodFloor());
        domain.setPaybackPeriodUpper(this.getPaybackPeriodUpper());
        domain.setPaybackPeriodStep(this.getPaybackPeriodStep());
        domain.setMerchantCode(this.getMerchantCode());
        domain.setOtherConfigData("");
        domain.setApplyRate(this.getApplyRate());
        domain.setCategoryDesc(this.getCategoryDesc());
        domain.setCategoryType(this.getCategoryType());
        domain.setLogo(this.getLogo());
        domain.setDailyApplyLimit(this.getDailyApplyLimit());
        domain.setEffectiveStartTime(this.getEffectiveStartTime());
        domain.setEffectiveEndTime(this.getEffectiveEndTime());
        domain.setMerchantCode(this.getMerchantCode());
        domain.setMerchantDoaminUrl(this.getMerchantDoaminUrl());
        domain.setMerchantPublicKey(this.getMerchantPublicKey());
        domain.setSort(this.getSort());
        domain.setConfirmWithdrawProcess(this.getConfirmWithdrawProcess());
        domain.setExtraInfo(this.getExtraInfo());
        domain.setForGp(this.getForGp());
        return domain;
    }

    public ProductCategory newFacade() {
        ProductCategory productCategory = new ProductCategory();
        productCategory.setCode(code);
        productCategory.setName(name);
        productCategory.setMoneyFloor(moneyFloor.toString());
        productCategory.setMoneyUpper(moneyUpper.toString());
        productCategory.setMoneyStep(moneyStep.toString());
        productCategory.setIsSelling(isSelling);
        productCategory.setInterestStrategy(interestStrategy);
        productCategory.setPaybackPeriodFloor(paybackPeriodFloor);
        productCategory.setPaybackPeriodUpper(paybackPeriodUpper);
        productCategory.setPaybackPeriodUnit(paybackPeriodUnit);
        productCategory.setPaybackPeriodStep(paybackPeriodStep);
        productCategory.setMerchantCode(merchantCode);
        productCategory.setCategoryDesc(categoryDesc);
        productCategory.setCategoryType(categoryType);
        productCategory.setApplyRate(applyRate);
        productCategory.setLogo(logo);
        productCategory.setCategoryConfig(new CategoryConfig());
        productCategory.setDailyApplyLimit(dailyApplyLimit);
        productCategory.setEffectiveEndTime(effectiveEndTime);
        productCategory.setEffectiveStartTime(effectiveStartTime);
        productCategory.setMerchantDoaminUrl(merchantDoaminUrl);
        productCategory.setMerchantPublicKey(merchantPublicKey);
        productCategory.setMerchantCode(merchantCode);
        productCategory.setSort(sort);
        productCategory.setConfirmWithdrawProcess(confirmWithdrawProcess);
        productCategory.setExtraInfo(extraInfo);
        productCategory.setForGp(forGp);
        return productCategory;
    }

    public String getCode() {
        return code;
    }

    public  ProductCategoryEntity setCode(String code){
        this.code = code;
        return this;
    }

    public  String getName(){
        return this.name;
    }

    public  ProductCategoryEntity setName(String name){
        this.name = name;
        return this;
    }

    public  BigDecimal getMoneyFloor(){
        return this.moneyFloor;
    }

    public  ProductCategoryEntity setMoneyFloor(BigDecimal moneyFloor){
        this.moneyFloor = moneyFloor;
        return this;
    }

    public  BigDecimal getMoneyUpper(){
        return this.moneyUpper;
    }

    public  ProductCategoryEntity setMoneyUpper(BigDecimal moneyUpper){
        this.moneyUpper = moneyUpper;
        return this;
    }

    public  Integer getIsSelling(){
        return this.isSelling;
    }

    public  ProductCategoryEntity setIsSelling(Integer isSelling){
        this.isSelling = isSelling;
        return this;
    }

    public  String getInterestStrategy(){
        return this.interestStrategy;
    }

    public  ProductCategoryEntity setInterestStrategy(String interestStrategy){
        this.interestStrategy = interestStrategy;
        return this;
    }

    public  String getPaybackPeriodUnit(){
        return this.paybackPeriodUnit;
    }

    public  ProductCategoryEntity setPaybackPeriodUnit(String paybackPeriodUnit){
        this.paybackPeriodUnit = paybackPeriodUnit;
        return this;
    }

    public  Integer getPaybackPeriodFloor(){
        return this.paybackPeriodFloor;
    }

    public  ProductCategoryEntity setPaybackPeriodFloor(Integer paybackPeriodFloor){
        this.paybackPeriodFloor = paybackPeriodFloor;
        return this;
    }

    public  Integer getPaybackPeriodUpper(){
        return this.paybackPeriodUpper;
    }

    public  ProductCategoryEntity setPaybackPeriodUpper(Integer paybackPeriodUpper){
        this.paybackPeriodUpper = paybackPeriodUpper;
        return this;
    }

    public  BigDecimal getMoneyStep(){
        return this.moneyStep;
    }

    public  ProductCategoryEntity setMoneyStep(BigDecimal moneyStep){
        this.moneyStep = moneyStep;
        return this;
    }

    public  Integer getPaybackPeriodStep(){
        return this.paybackPeriodStep;
    }

    public  ProductCategoryEntity setPaybackPeriodStep(Integer paybackPeriodStep){
        this.paybackPeriodStep = paybackPeriodStep;
        return this;
    }

    public  Integer getSort(){
        return this.sort;
    }

    public  ProductCategoryEntity setSort(Integer sort){
        this.sort = sort;
        return this;
    }

    public  String getLogo(){
        return this.logo;
    }

    public  ProductCategoryEntity setLogo(String logo){
        this.logo = logo;
        return this;
    }

    public  Integer getApplyRate(){
        return this.applyRate;
    }

    public  ProductCategoryEntity setApplyRate(Integer applyRate){
        this.applyRate = applyRate;
        return this;
    }

    public  Integer getCategoryType(){
        return this.categoryType;
    }

    public  ProductCategoryEntity setCategoryType(Integer categoryType){
        this.categoryType = categoryType;
        return this;
    }

    public  String getCategoryDesc(){
        return this.categoryDesc;
    }

    public  ProductCategoryEntity setCategoryDesc(String categoryDesc){
        this.categoryDesc = categoryDesc;
        return this;
    }

    public  Integer getDailyApplyLimit(){
        return this.dailyApplyLimit;
    }

    public  ProductCategoryEntity setDailyApplyLimit(Integer dailyApplyLimit){
        this.dailyApplyLimit = dailyApplyLimit;
        return this;
    }

    public  Date getEffectiveStartTime(){
        return this.effectiveStartTime;
    }

    public  ProductCategoryEntity setEffectiveStartTime(Date effectiveStartTime){
        this.effectiveStartTime = effectiveStartTime;
        return this;
    }

    public  Date getEffectiveEndTime(){
        return this.effectiveEndTime;
    }

    public  ProductCategoryEntity setEffectiveEndTime(Date effectiveEndTime){
        this.effectiveEndTime = effectiveEndTime;
        return this;
    }

    public  String getMerchantDoaminUrl(){
        return this.merchantDoaminUrl;
    }

    public  ProductCategoryEntity setMerchantDoaminUrl(String merchantDoaminUrl){
        this.merchantDoaminUrl = merchantDoaminUrl;
        return this;
    }

    public  String getMerchantPublicKey(){
        return this.merchantPublicKey;
    }

    public  ProductCategoryEntity setMerchantPublicKey(String merchantPublicKey){
        this.merchantPublicKey = merchantPublicKey;
        return this;
    }

    public  Integer getConfirmWithdrawProcess(){
        return this.confirmWithdrawProcess;
    }

    public  ProductCategoryEntity setConfirmWithdrawProcess(Integer confirmWithdrawProcess){
        this.confirmWithdrawProcess = confirmWithdrawProcess;
        return this;
    }

    public  String getExtraInfo(){
        return this.extraInfo;
    }

    public  ProductCategoryEntity setExtraInfo(String extraInfo){
        this.extraInfo = extraInfo;
        return this;
    }

    public  Integer getForGp(){
        return this.forGp;
    }

    public  ProductCategoryEntity setForGp(Integer forGp){
        this.forGp = forGp;
        return this;
    }
}
